// ----------------------------------------------------------------------------
/**
	File: maximumsum.cpp
	Author: Zef RosnBrick
	Archive: UVa
	Problem Number: 108
*/
// ----------------------------------------------------------------------------

#include <iostream>
#include <cstdio>
#include <algorithm>

#define INF 1000000000

using namespace std;

int max1Dsum(int C[100], int r)
{
	int p_sum = 0, max_sum = C[0], min_sum = 0;

	for (int i = 0; i < r; i++)
	{
		p_sum += C[i];
		max_sum = max(max_sum, p_sum - min_sum);
		min_sum = min(min_sum, p_sum);
	}

	return max_sum;
}

int max2Dsum(int M[][100], int r, int c)
{
	int m = -INF, P[100][100] = { 0 }, C[100];

	for (int i = 0; i < r; i++)
		for (int j = 0; j < c; j++)
			P[i][j] = M[i][j] + ((j > 0) ? P[i][j - 1] : 0);

	for (int rc = 0; rc < c; rc++)
		for (int lc = 0; lc <= rc; lc++)
		{
			for (int i = 0; i < r; i++)
				C[i] = P[i][rc] - ((lc > 0) ? P[i][lc - 1] : 0);

			m = max(m, max1Dsum(C, r));
		}

	return m;
}

int main()
{
	int caseno = 0, n, M[100][100];

	while (++caseno)
	{
		if (!(cin >> n) || n == 0)
			return 0;

		for (int i = 0; i < n; i++)
			for (int j = 0; j < n; j++)
				cin >> M[i][j];

		cout << max2Dsum(M, n, n) << endl;
	}
}
